package com.reggie.lotterysystem.dao.mapper;

import com.reggie.lotterysystem.dao.dataobject.ActivityDO;
import com.reggie.lotterysystem.dao.dataobject.ActivityPrizeDO;
import jakarta.validation.constraints.NotNull;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ActivityPrizeMapper {


    int batchInsert(List<ActivityPrizeDO> activityPrizeDOList);

    @Select("select * from activity_prize where activity_id = #{activityId} and prize_id = #{prizeId}")
    ActivityPrizeDO selectByAPId(@NotNull(message = "活动id不能为空") Long activityId, @NotNull(message = "奖品id不能为空") Long prizeId);

    @Select("select count(1) from activity_prize where activity_id = #{activityId} and status = #{status}")
    int countPrize(Long activityId, String status);

    @Select("select * from activity_prize where activity_id = #{activityId}")
    List<ActivityPrizeDO> selectByActivityId(Long activityId);

    @Update("update activity_prize set status = #{status} where activity_id = #{activityId} and prize_id = #{prizeId}")
    void updateStatus(Long activityId, Long prizeId, String status);
}
